<div class="main-title">
    <h1 class="float-left">Teams</h1>
    <span class="controls">
		<?php if (Yii::app()->user->checkAccess('ManageAgency.User.Manage')): ?>		
        <a class="link-button with-icon" href="<?php echo $this->createUrl('teams/create'); ?>">
            <img src="/images/icons/fugue/plus.png" />
            Add Team
        </a>
		<?php endif; ?>
    </span>
</div>
<div class="grid_16">
    <?php
    $this->widget('zii.widgets.grid.CGridView', array(
        'id' => 'admin-users-grid',
        'dataProvider' => $dataProvider,
        'filter' => $agencyTeam,
        'template' => '{pager}{items}',
        'htmlOptions' => array(
            'class' => 'grid-view no-shadow'
        ),
        'rowCssClassExpression' => '($row % 2 == 0 ? "even" : "odd")',
        'columns' => array(
            'name' => array(
                'name' => 'name',
                'type' => 'raw',
                'value' => 'CHtml::link($data->name, array("teams/update", "id" => $data->id), array("class" => "bold blue link"))',
                'htmlOptions' => array(
                    'class' => 'name',
                )
            ),
			array(
				'header' => 'Agency',
				'name' => 'agencyName',
				'type' => 'raw',
				'value' => '$data->agency->name',
				'filter' => false,
				'headerHtmlOptions' => array('width' => 120),
				'htmlOptions' => array('class' => 'agency-column no-wrap'),
				'visible' => Yii::app()->user->hasMultipleAgenciesSelected()
			),
            'num_members' => array(
                'header' => 'No. of Members',
                'value' => 'User::model()->ofCurrentAgency()->countByAttributes(array("agency_team_id" => $data->id))',
                'htmlOptions' => array(
                    'class' => 'align-center',
                    'width' => 90
                )
            )
        )
    ));
    ?>
</div>